package com.wing.member.model.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonValue;
import com.wing.mybatis.common.BaseEntity;
import com.wing.web.utils.LocaleMessage;
import lombok.Data;

import java.io.UnsupportedEncodingException;
import java.time.LocalDateTime;

/**
 * 用户信息
 *
 * @author
 */
@Data
@TableName("mem_member")
public class Member extends BaseEntity<Member> {

    public enum Type implements IEnum<Integer> {

        app(0, "App");

        private int code;
        private String desc;

        Type(int code, String desc){
            this.code = code;
            this.desc = desc;
        }

        @Override
        public Integer getValue() {
            return this.code;
        }

        @JsonValue
        public String getDesc(){
            return this.desc;
        }
    }

    public enum Sex implements IEnum<Integer> {

        male(0, "member.enum.sex.male"),
        female(1, "member.enum.sex.female");

        private int code;
        private String desc;

        Sex(int code, String desc){
            this.code = code;
            this.desc = desc;
        }


        @Override
        public Integer getValue() {
            return this.code;
        }

        @JsonValue
        public String getDesc() throws UnsupportedEncodingException {
            return LocaleMessage.getMessageByBaseName("language.member.member", this.desc);
        }

    }

    /**
     * 类型
     */
    private Type type;

    /**
     * 用户名
     */
    private String username;

    /**
     * 昵称
     */
    private String nickname;

    /**
     * 手机号
     */
    private String phone;

    /**
     * 邮箱
     */
    private String email;

    /**
     * 性别
     */
    private Sex sex;

    /**
     * 生日
     */
    private LocalDateTime birthday;

    /**
     * 住址
     */
    private String address;

    /**
     * 头像地址
     */
    private String headImg;

    /**
     * 个性签名
     */
    private String signature;

    /**
     * 邀请码ID
     */
    private Long inviteId;

    /**
     * 邀请码
     */
    private String inviteCode;

    /**
     * 支付密码
     */
    @JsonIgnore
    private String payPassword;

    /**
     * 加盐
     */
    @JsonIgnore
    private String salt;

    /**
     * 真实姓名
     */
    private String realName;

    /**
     * 身份证
     */
    private String idCard;

    /**
     * 手持身份证图片
     */
    private String handCardImage;

    /**
     * 身份证正面
     */
    private String cardFrontImage;

    /**
     * 身份证背面
     */
    private String cardBackImage;

    /**
     * 父级ID
     */
    @JsonIgnore
    private Long parentId;

    /**
     * 等级ID
     */
    @JsonIgnore
    private Long rankId;

    /**
     * 等级数
     */
    private Integer rankNumber;

    /**
     * 父级用户名
     */
    @TableField(exist = false)
    private String parentUsername;

    /**
     * 用户等级名称
     */
    @TableField(exist = false)
    private String rankName;


}
